<?php

class MusicLibraryController extends Controller
{
	public $sublayout = "/layouts/music"; 

	public function actions()
	{
		return array(
			'getSong'=> 'application.controllers.MusicLibrary.GetSongAction',
			'editSong'=> 'application.controllers.MusicLibrary.EditSongAction',
			'infoSong'=> 'application.controllers.MusicLibrary.InfoSongAction',
		);
	}
	public function filters()
    {
        return array(
            'checkSongId + getSong, editSong, infoSong',
			'checkPlaylistId + playPlaylist, editPlaylist, m3uPlaylist',
        );
    }
	
	public function filterCheckSongId($filterChain)
	{
		if (isset($_GET['songid']) && ($d = URLHelper::DecodeId($_GET['songid'], true)) ) {
			$_GET['songid'] = $d;
			//check $_GET['songid'] in DB
			$filterChain->run();
		} else
		{
			throw new CHttpException(404,'songid');
		}
	}
	public function filterCheckPlaylistId($filterChain)
	{
		if (isset($_GET['playlistid']) && ($d = URLHelper::DecodeId($_GET['playlistid'])) ) {
			$_GET['playlistid'] = $d;
			//check $_GET['playlistid'] in DB
			$filterChain->run();
		} else
		{
			throw new CHttpException(404,'playlistid');
		}
	}
	
	public function actionIndex()
	{
		$this->render('//site/index');
	}
	public function actionPlayPlaylist($playlistid)
	{
		echo "Play pl:".$playlistid;//$this->render('index');
	}
	public function actionEditPlaylist($playlistid)
	{
		echo "edit pl:".$playlistid;//$this->render('index');
	}
	public function actionM3uPlaylist($playlistid)
	{
		echo "getm3u:".$playlistid;//$this->render('index');
	}
}